//
//  MyTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/20.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "MyTableViewCell.h"

@interface MyTableViewCell()

@property(nonatomic, retain) UIImageView *image;

@property(nonatomic, retain) UILabel *title;

@end

@implementation MyTableViewCell

- (void)dealloc
{
    [_imageName release];
    [_titleName release];
    [_image release];
    [_title release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.image = [[UIImageView alloc]init];
        [self.contentView addSubview:self.image];
        [_image release];
        
        self.title = [[UILabel alloc]init];
        self.title.font = [UIFont systemFontOfSize:17 * kWidth];
        self.title.textColor = [UIColor blackColor];
        [self.contentView addSubview:self.title];
        [_title release];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.image.frame = CGRectMake(self.frame.size.width / 2 - 70, 20 * kHeight, 30 * kWidth, 30 * kHeight);
    self.title.frame = CGRectMake(self.frame.size.width / 2 - 15, 20 * kHeight, 150 * kWidth, 40 * kHeight);
}

-(void)setImageName:(NSString *)imageName
{
    if (_imageName != imageName) {
        [_imageName release];
        _imageName = [imageName retain];
    }
    
    self.image.image = [UIImage imageNamed:imageName];
}

-(void)setTitleName:(NSString *)titleName
{
    if (_titleName != titleName) {
        [_titleName release];
        _titleName = [titleName retain];
    }
    
    self.title.text = titleName;
}

@end
